<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta name="renderer" content="ie-comp">
<html>
<head>
    <title>手工补录</title>
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    <script type="text/javascript">
        var path = "${path}";
        var params = new Object();
        var manFlag = "1";//手工补录标志
        var url = path + "/system/cronjob/Manual";
        $(function () {
            setFromValue();
            onSpringId();
        });

        //获取选中行数据
        function setFromValue() {
            var rows = parent.$('#tt').datagrid('getSelections');
            var rowData = rows[0];
            $("#jobId").val(rowData.jobId);
            $("#jobName").val(rowData.jobName);

            if (rowData.validMark == "1") {
                $("#validMark").val("启动");
            } else if (rowData.validMark == "0") {
                $("#validMark").val("停止");
            }
            if (rowData.isConcurrent == "1") {
                $("#isConcurrent").val("否");
            } else if (rowData.isConcurrent == "0") {
                $("#isConcurrent").val("是");
            }
            $("#remark").val(rowData.remark);

            $("#beanId").val(rowData.beanId);
            $("#methodCall").val(rowData.methodCall);
           // $("#cron").val(rowData.cron);

            $("#jobGroup").val(rowData.jobGroup);
            $("#beanClass").val(rowData.beanClass);
            $.parser.parse();
        }


        function btnUpdateCron() {
            parent.layer.open({
                type: 2,
                title: '更新cron',
                shadeClose: false,
                shade: 0.6,
                area: ['860px', '510px'],
                content: '${path}/system/cronjob/toAddCron?win=' + window.name,
                success : function(layero, index) {
                },
                end : function(){
                    $.parser.parse();
                }
            });
        }


        //提交
        function btnSubmitAdd() {
            if (!validform("jsForm")) {
                return;
            }
            //区分是否为手工补录
            params.manFlag = manFlag;
            //设置任务状态
            if ($("#validMark").val() == "启动") {
                params.validMark = "1";
            } else if ($("#validMark").val() == "停止") {
                params.validMark = "0";
            }
            //设置是否有状态状态
            if ($("#isConcurrent").val() == "否") {
                params.isConcurrent = "1";
            } else if ($("#isConcurrent").val() == "是") {
                params.isConcurrent = "0";
            }

            $("#jsForm").ajaxSubmit({
                type: "POST",
                url: url,
                dataType: "json",
                data: params,
                async: false,

                success: function callback(data) {
                    var analyMsg = data;
                    if (analyMsg.code != '0000') {
                        $.messager.alert('操作提示', analyMsg.msg, 'info', function () {
                        });
                    } else {
                        $.messager.alert("操作提示", "手动补录成功！", "info", function () {
                            parent.btnQuery();
                            setTimeout("closeLayer()", 100);//设置延时，防止IE下出现异常
                        });
                    }
                },
                error: function (data, textstatus) {
                    $.messager.alert('操作提示', data.responseText, 'info', function () {
                    });
                }
            });
        }

        function btnCancelAdd() {
            closeLayer();
        }

        function onSpringId() {
            //自定义规则
            $.extend($.fn.validatebox.defaults.rules, {
                onSpringId: {
                    validator: function (value, param) {
                        if ($("#methodCall").val() != "") {
                            return false;
                        } else {
                            return true;
                        }
                    },
                    message: '方法名已存在，此项不用输入！'
                }
            });
        }

    </script>
</head>

<body style="margin:5px; padding:0px;">
<input type="hidden" id="txt_id"/>
<div class="easyui-layout" fit="true">
    <div id="AddDlgDiv" align="center">
        <form id="jsForm" method="post">
            <input type="hidden" id="jobId" name="jobId"/>
            <table class="f_table" cellspacing="1" align="center">
                <tr>
                    <td align="right" class="s_bg" style="width:133px">任务名称：</td>
                    <td class="s_bg" style="width: 160px">
                        <input type="text" id="jobName" name="jobName" class="easyui-validatebox"
                               data-options=" required:true,validType:'maxLength[60]'" style="width: 98%;"/></td>
                    <td align="right" class="s_bg" style="width:133px">任务状态：</td>
                    <td><select id="validMark" class="easyui-validatebox"
                                data-options="required:true,tipPosition:'left'"
                                style="width: 98%;">
                        <option></option>
                        <option>启动</option>
                        <option>停止</option>
                    </select></td>
                    <td align="right" class="s_bg" style="width:133px">BEAN_ID：</td>
                    <td class="s_bg" style="width: 160px;">
                        <input type="text" id="beanId" name="beanId" class="easyui-validatebox"
                               data-options="required:true,validType:['maxLength[60]']" style="width:98%;"/></td>
                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">方法名：</td>
                    <td class="s_bg" style="width: 160px;">
                        <input type="text" id="methodCall" name="methodCall" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[20]'" style="width:98%;"/></td>
                    <td align="right" class="s_bg" style="width:133px">cron表达式：</td>
                    <td class="s_bg" style="width: 160px;">
                        <input type="text" id="cron" name="cron" readOnly="readOnly"
                               data-options="required:true,validType:'maxLength[60]'" style="width:98%;"/></td>
                    <td class="s_bg" style="width: 160px;" colspan="2">
                        <span type="button" onclick="btnUpdateCron()">设置</span>
                    </td>

                </tr>
                <tr>
                    <td align="right" class="s_bg" style="width:133px">任务是否有状态：</td>
                    <td>
                        <select id="isConcurrent" class="easyui-validatebox"
                                data-options="required:true,tipPosition:'left'" style="width: 98%;">
                            <option></option>
                            <option>是</option>
                            <option>否</option>
                        </select></td>
                    <td align="right" class="s_bg" style="width:133px">任务分组：</td>
                    <td class="s_bg" style="width: 160px">
                        <input type="text" id="jobGroup" name="jobGroup" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[100]'" style="width: 98%;"/></td>
                    <td align="right" class="s_bg" style="width:133px">任务调用的方法名：</td>
                    <td class="s_bg" style="width: 160px;">
                        <input type="text" id="beanClass" name="beanClass" class="easyui-validatebox"
                               data-options="required:true,validType:'maxLength[100]'" style="width:98%;"/></td>
                </tr>

            </table>
        </form>
        <div align="center" style="margin-top: 15px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="btnSubmitAdd()">确定</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel"
               onclick="btnCancelAdd();">取消</a>
        </div>
    </div>
</div>
</body>
</html>
